package com.xlh.dao.statistic.helper;

import cn.hutool.core.collection.CollectionUtil;
import com.xlh.dao.statistic.StatisticStudentCourseMapper;
import com.xlh.dao.support.StatisticsMapper;
import com.xlh.pojo.statistic.StatisticStudentCourse;
import com.xlh.pojo.statistic.StatisticStudentCourseExample;
import com.xlh.pojo.support.Statistics;
import com.xlh.pojo.support.StatisticsExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class StatisticsStudentCourseMapperHelper {

    @Autowired
    private StatisticStudentCourseMapper courseMapper;


    public StatisticStudentCourse getByCondition(Long userId, Long courseId, Long classId){

        StatisticStudentCourseExample example = new StatisticStudentCourseExample();
        example.createCriteria().andUserIdEqualTo(userId).andCourseIdEqualTo(courseId).andClassIdEqualTo(classId);
        List<StatisticStudentCourse> statisticStudentCourses = courseMapper.selectByExample(example);

        if(CollectionUtil.isNotEmpty(statisticStudentCourses)){

            return statisticStudentCourses.get(0);
        }

        return null;
    }



}
